package com.benyanyi.picker.base;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

/**
 * @author YanYi
 * @date 2020/6/24 15:16
 * @email ben@yanyi.red
 * @overview
 */
public abstract class BaseDialogRecyclerAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> {
    private OnItemListener itemListener;

    @Override
    public void onBindViewHolder(@NonNull VH holder, final int position) {
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (itemListener != null) {
                    itemListener.onItemListener(position);
                }
            }
        });
    }

    public void setOnItemListener(OnItemListener itemListener) {
        this.itemListener = itemListener;
    }

    public interface OnItemListener {
        void onItemListener(int position);
    }
}